#include <stdio.h>
#include <fcntl.h>

int main(int argc, char *argv[])
{
    int fd;
    int counter, old_counter;

    counter     = 0;
    old_counter = 0;

    /* 打开/dev/sec_dev设备文件 */
    fd = open("/dev/sec_dev", O_RDONLY);
    if(fd != -1)
    {
        while(1)
        {
            /* 读取目前经历的秒数 */
            read(fd, &counter, sizeof(unsigned int));
            if(counter != old_counter)
            {
                printf("seconds after open /dev/sec_dev :%d\n", counter);
                old_counter = counter;
            }
        }
    }
    else
    {
        printf("Device open failure\n");
    }

    return 0;
}
